﻿using System;
using Internal.Runtime;
using Runtime.Models;

namespace Runtime {

    /// <summary>
    /// 数据中心
    /// </summary>
    public class DFR_BattleDataCenterBase : IDFR_BattleDataCenterBaseInternal, IDisposable {

        /// <summary>
        /// 运行时数据
        /// </summary>
        public IDFR_BattleModelsBase Models => m_Models;

        protected IDFR_BattleModelsBase m_Models;

        void IDFR_BattleDataCenterBaseInternal.NewModels() {
            m_Models = KHBD.TypeMap.Instantiate<IDFR_BattleModelsBase>();
        }

        void IDisposable.Dispose() {
            if (m_Models is IDisposable disposable) {
                disposable.Dispose();
            }
            m_Models = null;
        }
    }
}

namespace Internal.Runtime {

    public interface IDFR_BattleDataCenterBaseInternal {

        void NewModels();
    }
}
